<template>
  <div class="menuNavigation-box" :class="{ 'menuNavigation-item-wap': store.isMobileType }">
    <div @click="openprogres" id="menuNavigation-item" class="menuNavigation-item">
      <t-popup
        class="placement align"
        content="展览定位"
        placement="left"
        attach="#menuNavigation-tem"
        showArrow
        destroyOnClose
      >
        <div class="item-left" :class="{ 'is-hover': store.isMobileType }">
          <div class="item-content freeIcon">&#xe663;</div>
          <img class="item-bg" :src="publicUrls + 'free/style16/menuNavigationItemLeft1.png'" alt="" />
        </div>
      </t-popup>
    </div>
    <div @click="handleMouseEnter(1)" id="menuNavigation-item" class="menuNavigation-item">
      <t-popup
        class="placement align"
        content="单元目录"
        placement="left"
        attach="#menuNavigation-tem"
        showArrow
        destroyOnClose
      >
        <div class="item-left" :class="{ 'is-hover': store.isMobileType }">
          <div class="item-content doorIcon">&#xe679;</div>
          <img class="item-bg" :src="publicUrls + 'free/style16/menuNavigationItemLeft1.png'" alt="" />
        </div>
      </t-popup>
    </div>
    <div @click="handleMouseEnter(2)" class="menuNavigation-item">
      <t-popup
        class="placement align"
        content="更多板块"
        placement="left"
        attach="#menuNavigation-tem"
        showArrow
        destroyOnClose
      >
        <div class="item-left" :class="{ 'is-hover': store.isMobileType }">
          <div class="item-content doorIcon">&#xe67a;</div>
          <img class="item-bg" :src="publicUrls + 'free/style16/menuNavigationItemLeft1.png'" alt="" />
        </div>
      </t-popup>
    </div>
    <!-- 关注 -->
    <div class="menuNavigation-item" @click="follow" v-if="!store.isMobileType">
      <t-popup
        class="placement align"
        content="收藏此展览"
        placement="left"
        attach="#menuNavigation-tem"
        showArrow
        destroyOnClose
      >
        <div class="item-left">
          <div v-if="commonStore.isStart" class="item-content doorIcon item-start start-active">&#xe629;</div>
          <div v-else class="item-content doorIcon item-start">&#xe628;</div>
          <img class="item-bg" :src="publicUrls + 'free/style16/menuNavigationItemLeft1.png'" alt="" />
        </div>
      </t-popup>
    </div>
    <!-- 分享 -->
    <div class="menuNavigation-item menuNavigation-1" v-if="!store.isMobileType">
      <t-popup
        class="placement align"
        content=""
        placement="left"
        attach="#menuNavigation-tem"
        destroyOnClose
        :trigger="store.isMobileType ? 'click' : 'hover'"
        :overlay-inner-style="(triggerElem) => ({ background: `transparent`, 'box-shadow': 'none' })"
      >
        <template #content>
          <Shear @shearType="shearType" />
        </template>
        <div class="item-left">
          <div class="item-content doorIcon item-content-share">&#xe647;</div>
          <img class="item-bg" :src="publicUrls + 'free/style16/menuNavigationItemLeft1.png'" alt="" />
        </div>
      </t-popup>
    </div>
    <div
      @wheel="pageWheel"
      class="shadow"
      @click="close"
      v-if="(showType === 1 || showType === 2 || showType === 4) && show"
    ></div>

    <!-- 展开目录 -->
    <div
      class="scroll-box"
      :class="showType === 1 || showType === 2 || showType === 4 ? 'scroll-box-active' : 'scroll-box-down'"
    >
      <div class="scroll-box-content" :class="showType == 2 && 'scroll-box-content2'">
        <div class="scroll-box-content-component">
          <div class="content-title-parent">
            {{ showType == 1 ? '单元目录' : showType == 2 ? '更多板块' : showType == 4 ? '分享' : '' }}
          </div>
          <div class="list">
            <div class="list-content" v-if="showType === 1">
              <div
                class="item"
                :class="listId == item.id && 'item-active'"
                @click="scroolPath(item.id)"
                v-for="item in store.templateMOdeList"
                :key="item.id"
              >
                <p class="item-title" :class="!store.isMobileType && 'item-hover'">{{ item.text }}</p>
              </div>
            </div>
            <div class="list-content list-content-mg" v-else-if="showType === 2">
              <RouterList @emitPath="scrollHandleMouseLeave" />
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template> 
 
<script lang="ts">
export default defineComponent({
  name: 'style16',
});
</script>

<script setup lang="ts">
import { getHeardToken } from '@/api/utils';
import { psthOutline } from '@/hooks/menuHooks';
import RouterList from '../menuComponent/routerList16.vue';
import { publicUrls } from '@/utils/minxin';
import { ref, reactive, watch, nextTick, computed, defineComponent } from 'vue';
import { useProjectStore } from '@/store';
import ScrollBox from '../scrollBox.vue';
import style1 from './style/style1.vue';
import { commonDataStore } from '@/store';
import { toQQ, toQQzone, toWeibo } from '@/utils/shear';
import { AddFollow } from '@/api/door/door';
import Shear from '../menuComponent/templateShear.vue';
import { useRoute, useRouter } from 'vue-router';

const props = defineProps({
  isMobile: {
    type: Boolean,
  },
});
const commonStore = commonDataStore();
const show = ref(false);
const showType = ref(0);
const listId = ref(0);
const store = useProjectStore();
const visibleMessage = ref(false);
const FollowType = ref(false);
const router = useRouter();
const route = useRoute();
const Scrollwidth = ref();
const shareList = reactive([
  {
    icon: '\ue623',
    text: '分享此展览到QQ',
  },
  {
    icon: '\ue616',
    text: '分享此展览到QQ空间',
  },
  {
    icon: '\ue615',
    text: '分享此展览到微博',
  },
]);
const openprogres = () => {
  store.setprogressVisible();
};
commonStore.getMenuList();
const handleMouseEnter = (type: number) => {
  showType.value = type;
  show.value = true;
};

let viewportwidth = window.innerWidth;
Scrollwidth.value = (viewportwidth / 900) * 300;

const getScrollWidth = computed(() => {
  let widths = (window.innerWidth / 900) * 300;
  return widths;
});

const mouseenterHover = () => {};

const scrollHandleMouseLeave = () => {
  showType.value = 0;
  show.value = false;
};
const scroolPath = (id: number) => {
  if (route.name !== 'templateedit') {
    router.push({ name: route.meta.loopType ? 'exhibitionHome' : 'templateedit' });
    store.menuId = null;
  }

  setTimeout(() => {
    psthOutline('Level1outline' + id);
    scrollHandleMouseLeave();
    listId.value = id;
  }, 200);
};
const follow = () => {
  let token = getHeardToken();
  if (!token) {
    // visibleMessage.value = true;
    store.loginModeShow = true;
    return;
  } else {
    commonStore.setFollow();
    handleMouseEnter(3);
  }
};
const pageWheel = (event: any) => {
  const delta = Math.sign(event.wheelDelta || -event.detail);
  const scrollContainer = document.getElementById('edit-scroll-box');
  if (delta > 0) {
    if (scrollContainer.scrollLeft === 0) {
    } else {
      scrollContainer.scrollLeft = scrollContainer.scrollLeft - 100;
    }
  } else {
    scrollContainer.scrollLeft = scrollContainer.scrollLeft + 100;
  }
  event.preventDefault();

  // scrollRef
};
//分享
const shearType = (e: number) => {
  let url = window.location.href;
  let title = '';
  handleMouseEnter(4);
  switch (e) {
    case 0:
      toQQ(url, title);
      break;
    case 1:
      toQQzone(url, title);
      break;
    case 2:
      toWeibo(url, title);
      break;
  }
  scrollHandleMouseLeave();
};

//取消登录
const closeClick = () => {
  visibleMessage.value = false;
};
const close = () => {
  showType.value = 0;
  show.value = false;
};
//确认登录
const pathSubmitClick = () => {
  visibleMessage.value = false;
  let url = window.location.href;
  let redirectUrl = 'http://wz.wuzhan.art/#/login?redirect=' + url;
  window.location.href = redirectUrl;
};
</script>

<style lang="less" scoped>
a {
  color: #000;
  &:hover {
    color: #000;
  }
}
.menuNavigation-box {
  display: flex;
  flex-direction: column;
  position: fixed;
  bottom: 40px;
  right: -77px;
  // right: 0px;
  width: 144px;
  z-index: 999;
}
.is-hover {
  width: 65px !important;
  height: 65px !important;
  max-width: 65px !important;
  max-height: 65px !important;
}
.menuNavigation-1 {
}
.menuNavigation-item {
  position: relative;
  cursor: pointer;
  display: flex;
  align-items: center;
  width: 144px;
  margin-top: 4px;
  transition: all 0.3s;
  z-index: 999;
  // transform: translateZ(1px);

  ::v-deep .t-popup__content {
    box-shadow: none;
    padding: 4px 10px;
    font-size: 16px;
    line-height: 24px;
    color: #663e30;
    background: #f8f6f3;
    box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.15);
  }
  ::v-deep .t-popup__arrow::before {
    background: #f8f6f3;
    box-shadow: none;
  }
}
.item-content-share {
  margin-right: 2px;
}
.item-left {
  position: relative;
  width: 50px;
  height: 50px;
  max-width: 60px;
  max-height: 60px;
  z-index: 30;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 16px;
  .item-bg {
    width: 100%;
    height: 100%;
    object-fit: contain;
    position: absolute;
    left: 0;
    top: 0;
    transition: all 0.3s ease;
  }
  .item-content {
    width: 38px;
    height: 38px;
    font-size: 20px;
    color: #6d8472;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    z-index: 1;
  }
  .item-start {
    font-size: 24px !important;
  }
  .start-active {
    color: #fff;
  }
}
.item-right {
  display: flex;
  align-items: center;
  width: 119px;
  height: 44px;
  margin-left: -25px;
  padding-left: 29px;
  border: 1px solid rgba(255, 255, 255, 0.63);
  background: rgba(255, 255, 255, 0.8);
  span {
    font-family: SourceHanSerifCN-Bold;
    font-size: 16px;
    line-height: 32px;
    text-align: left;
    color: rgba(173, 144, 114, 1);
  }
}
.scroll-box {
  display: flex;
  align-items: center;
  position: fixed;
  bottom: 40px;
  right: 102px;
  z-index: 220;
  transform: translateZ(1px);
}
.shadow {
  position: fixed;
  top: 0;
  left: 0;
  width: 1440px;
  height: 900px;
}
.scroll-box-content2 {
  width: 202px !important;
  height: 438px !important;
}
.scroll-box-content {
  width: 326px;
  height: 454px;
  background: url('https://static.jiyi.show/free/style16/scrollContentBg.png') no-repeat center/100% 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  padding: 40px 15px 40px 15px;
  position: relative;
  .cancel {
    width: 40px;
    height: 40px;
    position: absolute;
    top: 10px;
    right: 32px;
    cursor: pointer;
    z-index: 1;
  }
}
.scroll-box-content-component {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.content-title-parent {
  width: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-family: 'SourceHanSerifCN-Bold';
  font-size: 20px;
  color: #663e30;
  line-height: 180%;
}
.list {
  width: 100%;
  height: 100%;
  overflow: auto;
  margin-top: 30px;
}
.list::-webkit-scrollbar {
  display: none;
}
.list-content {
  width: 100%;
}
.list-content-mg {
  display: flex;
  justify-content: center;
}
.list-active {
  background: #ffdc76;
  border-top: 1px solid #212326;
  border-bottom: 1px solid #212326;
  & > p {
    font-family: SourceHanSerifCN-Bold !important;
  }
}
.item {
  // width: 318px;
  width: 100%;
  display: flex;
  justify-content: center;
  height: 40px;
  &:last-child {
    margin-bottom: 0;
  }
}
.item-share {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 32px;
  margin-bottom: 16px;
  &:first-child {
    margin-top: 16px;
  }
  &:hover {
    .item-share-title {
      text-decoration: underline;
      opacity: 1;
    }
  }
  .doorIcon {
    font-size: 20px;
    margin-right: 4px;
  }
  .freeIcon {
    font-size: 20px !important;
  }
  .item-share-title {
    width: 156px;
    font-family: SourceHanSerifCN;
    font-size: 16px;
    line-height: 30px;
    color: #212326;
    cursor: pointer;
    opacity: 0.8;
  }
}

::v-deep .solid-box-parent {
  right: 20px;
}
.solidBorder-child {
  width: 2px;
  height: 100%;
  background: rgba(79, 110, 92, 0.2);
  border-radius: 2px;
}

::v-deep .shadow-box-shadow {
  background: rgba(241, 239, 234, 0.95) !important;
}
.item-title {
  cursor: pointer;
  font-family: PingFangSC !important;
  line-height: 40px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  color: #777;
}
.item-hover:hover {
  color: #663e30;
  text-decoration-line: underline;
}
.item-active {
  background: url('https://static.jiyi.show/free/style16/listhover.png') no-repeat center/100% 100%;
  .item-title {
    color: #333 !important;
  }
}
.scroll-box-down {
  // transition: all 0.3s;
  width: 420px;
  opacity: 0;
  display: none;
  height: 0;
  .scroll-box-content {
    overflow: auto;
  }
}
.menuNavigation-item-wap {
  bottom: 100px;

  .menuNavigation-item {
    // transform: translateZ(1px);
    transform: scale(1.5) translateZ(2px);
    margin-top: 42px;
  }
  .scroll-box {
    transform: scale(1.3) translateZ(2px);
    margin-bottom: 80px;
    right: 210px;
  }
  ::v-deep .t-popup {
    display: none;
  }
}
</style>